package mo.offer_version2;

import java.util.Deque;
import java.util.LinkedList;

public class L30 {

    private Deque<Integer> xStack;
    private Deque<Integer> mStack;

    /** initialize your data structure here. */
    public L30() {
        xStack = new LinkedList<>();
        mStack = new LinkedList<>();
        mStack.push(Integer.MAX_VALUE);
    }

    public void push(int x) {
        xStack.push(x);
        mStack.push(Math.min(mStack.peek(), x));
    }

    public void pop() {
        xStack.pop();
        mStack.pop();
    }

    public int top() {
        return xStack.peek();
    }

    public int min() {
        return mStack.peek();
    }

    public static void main(String[] args) {
        L30 test = new L30();
        test.push(5);
        test.push(3);
        test.push(4);
        System.out.println(test.min());
        test.pop();
        test.pop();
        System.out.println(test.top());
        System.out.println(test.min());
    }

}
